package com.SparkCore.Test

import java.io.{ObjectOutputStream, OutputStream}
import java.net.Socket


object Driver {
  def main(args: Array[String]): Unit = {
    val client1 = new Socket("localhost" , 1234 )
    val client2 = new Socket("localhost" , 2345 )

    val task = new Task()
    val out1: OutputStream = client1.getOutputStream
    val objectOutputStream1 = new ObjectOutputStream(out1)

    val subTask1 = new SubTask()
    subTask1.logic = task.logic
    subTask1.datas = task.datas.take(2)

    objectOutputStream1.writeObject(subTask1)
    objectOutputStream1.flush()
    objectOutputStream1.close()
    client1.close()

    val out2: OutputStream = client2.getOutputStream
    val objectOutputStream2 = new ObjectOutputStream(out2)

    val subTask2 = new SubTask
    subTask2.logic = task.logic
    subTask2.datas = task.datas.takeRight(2)

    objectOutputStream2.writeObject(subTask2)
    objectOutputStream2.flush()
    objectOutputStream2.close()
    client2.close()


    println("客户端发送完毕")
  }
}
